package com.xoomworks.rsfr.core.service;

import java.util.List;

import com.xoomworks.rsfr.model.BaseEntity;

/**
 * Base Service.
 *
 * @param <T>
 */

public interface BaseService<T extends BaseEntity> {

    /**
     * Finds the entity with a matching id.
     *
     * @param id
     *            represents the id of the searched entity
     * @return the entity or null if no entity is found with the id
     */
    T find(final Long id);

    /**
     * Finds all the entities.
     *
     * @return a List with all the entities
     */
    List<T> findAll();

    /**
     * Saves the entity.
     *
     * @param entity
     *            the entity which will be saved.
     * @return The saved entity's ID.
     */
    Long save(final T entity);

    /**
     * Updates the entity.
     *
     * @param entity
     *            the entity which will be updated.
     */
    void update(final T entity);

    /**
     * Deletes the entity by a given ID.
     *
     * @param entityId
     *            the ID of the entity which will be deleted.
     */
    void deleteById(final Long entityId);

}
